﻿using Abp.Application.Services;
using Abp.Authorization;
using Abp.Authorization.Users;
using Abp.AutoMapper;
using Microsoft.AspNet.Identity;
using RMM.Authorization;
using RMM.Authorization.Tenants;
using RMM.Core.Entity.Users;
using RMM.Core.UserService;
using RMM.FrameWork;
using RMM.UserAppService.Dtos;
using RMM.UserAdminService.Dtos;
using RMM.Users.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Configuration;

namespace RMM.UserAdminService
{
    public class UserAdminService : ApplicationService, IUserAdminService
    {
        private readonly IUserService _userService;

        public UserAdminService(IUserService userService)
        {
            _userService = userService;
        }


        public async Task<List<AdminUserDto>> GetUserListAsync()
        {
            var user = await _userService.GetUserListAsync();
            return user.MapTo<List<AdminUserDto>>();

        }

        public async Task<AdminUserDto> LoginAdminAsync(string username, string password)
        {
            var adminuser = new User();
            adminuser = await _userService.FirstOrDefaultAsync(p => p.UserName == username && p.Password == password);
            return adminuser?.MapTo<AdminUserDto>();
        }

        public async Task<AdminUserDto> GetUserByidAsync(int userId)
        {
            var proj = await _userService.FirstOrDefaultAsync(p => p.Id == userId);
            return proj.MapTo<AdminUserDto>();
        }
    }
}
